Test Series - Data Structure

Test Number 92/115

Q: Trie is also known as _________
A. Digital Tree
B. Treap
C. Binomial Tree
D. 2-3 Tree
Solution: Trie is a very useful data structure which is based on the prefix of a string. Trie is used to represent the “Retrieval” of data and thus the name Trie. And it is also known as a digital tree.
Q: What traversal over trie gives the lexicographical sorting of the set of the strings?
A. postorder
B. preorders
C. inorder
D. level order
Solution: In trie, we store the strings in such a way that there is one node for every common prefix. Therefore the inorder traversal over trie gives the lexicographically sorted set of strings.
Q: Which of the following is the efficient data structure for searching words in dictionaries?
A. BST
B. Linked List
C. Balancded BST
D. Trie
Solution: In a BST, as well as in a balanced BST searching takes time in order of mlogn, where m is the maximum string length and n is the number of strings in tree. But searching in trie will take O(m) time to search the key
Q: Which of the following special type of trie is used for fast searching of the full texts?
A. Ctrie
B. Hash tree
C. Suffix tree
D. T tree
Solution: Suffix tree, a special type of trie, contains all the suffixes of the given text at the key and their position in the text as their values. So, suffix trees are used for fast searching of the full texts.
Q: Which of the following is not true?
A. Trie requires less storage space than hashing
B. Trie allows listing of all the words with same prefix
C. Tries are collision free
D. Trie is also known as prefix tree
Solution: Both the hashing and the trie provides searching in the linear time. But trie requires extra space for storage and it is collision free. And trie allows finding all the strings with same prefix, so it is also called prefix tree.
Q: A program to search a contact from phone directory can be implemented efficiently using ______
A. a BST
B. a trie
C. a balanced BST
D. a binary tree
Solution: Dictionaries, phone directories can be implemented efficiently using the trie. Because it trie provides the efficient linear time searching over the entries.
Q: What can be the maximum depth of the trie with n strings and m as the maximum sting the length?
A. log2n
B. log2m
C. n
D. m
Solution: In the trie, the strings are stored efficiently based on the common prefixes. And trie has maximum fan-out 26 if english alphabets are considered. Owing to this, the maximum depth is equal to the maximum string length.
Q: Which of the following is true about the trie?
A. root is letter a
B. path from root to the leat yields the string
C. children of nodes are randomly ordered
D. each node stores the associated keys
Solution: A trie is an ordered tree where (i) the root represents an empty string(“”) (ii) each node other than root is labeled with a character (iii) the children of a nodes are lexicographically ordered (iv) the paths from the leaves to the root yields the strings.
Q: Auto complete and spell checkers can be implemented efficiently using the trie.
A. True
B. False
C. ....
D. ....
Solution: Trie provides fast searching and storing of the words. And tries stores words in lexicographical order so, trie is the efficient data structure for implementation of spell checkers and auto complete.

You Have Score    /9